package context

import (
	"kuangstudy-mall/apis/user-web/validation"
)

type UserContext struct {
	Mobile    string `json:"mobile" binding:"required,mobile" label:"手机号码"`
	Password  string `json:"password" binding:"required,min=3,max=20" label:"密码"`
	Captcha   string `json:"captcha" binding:"required,min=4,max=4" label:"验证码"`
	CaptchaId string `json:"captchaId" binding:"required" label:"验证码ID"`
}

func (ctx *UserContext) GetMessage() validation.ValidatorMessages {
	return validation.ValidatorMessages{
		"required":      "请输入%s",
		"mobile.mobile": "请输入合法手机号码",
		"password.min":  "密码长度必须大于等于3",
		"password.max":  "密码长度必须小于等于20",
	}
}

func (ctx *UserContext) TranslateMessage() validation.ValidatorMessages {
	return validation.ValidatorMessages{
		"mobile":   "手机xxx",
		"password": "密码xxx",
	}
}

type UserRegContext struct {
	NickName string `json:"nickname" binding:"required" label:"手机号码"`
	PassWord string `json:"password" binding:"required,min=3,max=20" label:"密码"`
	Mobile   string `json:"mobile" binding:"required,mobile" label:"手机号码"`
	Gender   string `json:"gender" binding:"required,gender" label:"性别"`
	BirthDay uint64 `json:"birthDay" binding:"required" label:"生日"`
}

func (ctx *UserRegContext) GetMessage() validation.ValidatorMessages {
	return validation.ValidatorMessages{
		"nickname.required": "请输入昵称",
		"gender.required":   "请输入性别",
		"gender.gender":     "性别必须是：male|woman",
		"birthDay.required": "请输入生日",
		"mobile.required":   "请输入手机号码",
		"mobile.mobile":     "请输入合法手机号码",
		"password.required": "请输入密码",
		"password.min":      "密码长度必须大于等于3",
		"password.max":      "密码长度必须小于等于20",
	}
}

func (ctx *UserRegContext) TranslateMessage() validation.ValidatorMessages {
	return validation.ValidatorMessages{
		"mobile":   "手机",
		"password": "密码",
	}
}
